import Vue from 'vue';
import VueRouter from 'vue-router';

Vue.use(VueRouter);

// 解决ElementUI导航栏中的vue-router在3.0版本以上重复点菜单报错问题
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}

export default new VueRouter({
    saveScrollPosition: true,
    routes: [
        {
            name: 'index',
            path: '/index',
            component: resolve => require(['../pages/index/Index.vue'], resolve),
            meta: {
                title: 'menu.index',
            }
        },
        {
            name: 'stats',
            path: '/stats',
            component: resolve => require(['../pages/stats/Index.vue'], resolve),
            meta: {
                title: 'menu.stats',
            }
        },
        {
            name: 'stats.summary',
            path: '/stats/summary',
            component: resolve => require(['../pages/stats/summary/Index.vue'], resolve),
            meta: {
                title: 'menu.stats.summary',
            }
        },
        {
            name: 'stats.user.player',
            path: '/stats/user/player',
            component: resolve => require(['../pages/stats/user/player/Index.vue'], resolve),
            meta: {
                title: 'menu.stats.user.player',
            }
        },
        {
            name: 'stats.user.retention',
            path: '/stats/user/retention',
            component: resolve => require(['../pages/stats/user/retention/Index.vue'], resolve),
            meta: {
                title: 'menu.stats.user.retention',
            }
        },
        {
            name: 'stats.user.player-bet',
            path: '/stats/user/player-bet',
            component: resolve => require(['../pages/stats/user/player-bet/Index.vue'], resolve),
            meta: {
                title: 'menu.stats.user.player-bet',
            }
        },
        {
            name: 'stats.game.game',
            path: '/stats/game/game',
            component: resolve => require(['../pages/stats/game/game/Index.vue'], resolve),
            meta: {
                title: 'menu.stats.game.game',
            }
        },
        {
            name: 'stats.game.best',
            path: '/stats/game/best',
            component: resolve => require(['../pages/stats/game/best/Index.vue'], resolve),
            meta: {
                title: 'menu.stats.game.best',
            }
        },
        {
            name: 'stats.platform.settlement',
            path: '/stats/platform/settlement',
            component: resolve => require(['../pages/stats/platform/settlement/Index.vue'], resolve),
            meta: {
                title: 'menu.stats.platform.settlement',
            }
        },
        {
            name: 'stats.platform.best',
            path: '/stats/platform/best',
            component: resolve => require(['../pages/stats/platform/best/Index.vue'], resolve),
            meta: {
                title: 'menu.stats.platform.best',
            }
        },
        {
            name: 'stats.risk.slo',
            path: '/stats/risk/slo',
            component: resolve => require(['../pages/stats/risk/slo/Index.vue'], resolve),
            meta: {
                title: 'menu.stats.risk.slo',
            }
        },
        {
            name: 'platform.setting',
            path: '/platform/setting',
            component: resolve => require(['../pages/platform/setting/Index.vue'], resolve),
            meta: {
                title: 'menu.platform.setting',
            }
        },
        {
            name: 'platform.user',
            path: '/platform/user',
            component: resolve => require(['../pages/platform/user/Index.vue'], resolve),
            meta: {
                title: 'menu.platform.user',
            }
        },
        {
            name: 'platform.settlement',
            path: '/platform/settlement',
            component: resolve => require(['../pages/platform/settlement/Index.vue'], resolve),
            meta: {
                title: 'menu.platform.settlement',
            }
        },
        {
            name: 'platform.doc',
            path: '/platform/doc',
            component: resolve => require(['../pages/platform/doc/Index.vue'], resolve),
            meta: {
                title: 'menu.platform.doc',
            }
        },
        {
            name: 'platform.config.betting',
            path: '/platform/config/betting',
            component: resolve => require(['../pages/platform/config/betting/Index.vue'], resolve),
            meta: {
                title: 'menu.platform.config.betting',
            }
        },
        {
            name: 'game.user',
            path: '/game/user',
            component: resolve => require(['../pages/game/user/Index.vue'], resolve),
            meta: {
                title: 'menu.game.user',
            }
        },
        {
            name: 'game.data.gameStatus',
            path: '/game/data/gameStatus',
            component: resolve => require(['../pages/game/data/gameStatus/Index.vue'], resolve),
            meta: {
                title: 'menu.game.data.gameStatus',
            }
        },
        {
            name: 'game.data.settlement',
            path: '/game/data/settlement',
            component: resolve => require(['../pages/game/data/settlement/Index.vue'], resolve),
            meta: {
                title: 'menu.game.data.settlement',
            }
        },
        {
            name: 'game.data.log-cost',
            path: '/game/data/log-cost',
            component: resolve => require(['../pages/game/data/log-cost/Index.vue'], resolve),
            meta: {
                title: 'menu.game.data.log-cost',
            }
        },
        {
            name: 'game.data.log-login',
            path: '/game/data/log-login',
            component: resolve => require(['../pages/game/data/log-login/Index.vue'], resolve),
            meta: {
                title: 'menu.game.data.log-login',
            }
        },
        {
            name: 'game.data.log-game',
            path: '/game/data/log-game',
            component: resolve => require(['../pages/game/data/log-game/Index.vue'], resolve),
            meta: {
                title: 'menu.game.data.log-game',
            }
        },
        {
            name: 'game.setting.server',
            path: '/game/setting/server',
            component: resolve => require(['../pages/game/setting/server/Index.vue'], resolve),
            meta: {
                title: 'menu.game.setting.server',
            }
        },
        {
            name: 'game.setting.domain',
            path: '/game/setting/domain',
            component: resolve => require(['../pages/game/setting/domain/Index.vue'], resolve),
            meta: {
                title: 'menu.game.setting.domain',
            }
        },
        {
            name: 'game.setting.game',
            path: '/game/setting/game',
            component: resolve => require(['../pages/game/setting/game/Index.vue'], resolve),
            meta: {
                title: 'menu.game.setting.game',
            }
        },
        {
            name: 'game.setting.config.index',
            path: '/game/setting/config',
            component: resolve => require(['../pages/game/setting/config/Index.vue'], resolve),
            meta: {
                title: 'menu.game.setting.config.index',
            }
        },
        {
            name: 'game.setting.config.basic',
            path: '/game/setting/config/basic/:game',
            component: resolve => require(['../pages/game/setting/config/basic/Index.vue'], resolve),
            meta: {
                title: 'menu.game.setting.config.index',
                hasPermission: 'game.setting.config.index',
            }
        },
        {
            name: 'game.setting.config.elementary',
            path: '/game/setting/config/elementary/:game',
            component: resolve => require(['../pages/game/setting/config/elementary/Index.vue'], resolve),
            meta: {
                title: 'menu.game.setting.config.index',
                hasPermission: 'game.setting.config.index',
            }
        },
        {
            name: 'game.setting.config.fishing',
            path: '/game/setting/config/fishing/:game',
            component: resolve => require(['../pages/game/setting/config/fishing/Index.vue'], resolve),
            meta: {
                title: 'menu.game.setting.config.index',
                hasPermission: 'game.setting.config.index',
            }
        },
        {
            name: 'game.setting.config.tiger',
            path: '/game/setting/config/tiger/:game',
            component: resolve => require(['../pages/game/setting/config/tiger/Index.vue'], resolve),
            meta: {
                title: 'menu.game.setting.config.index',
                hasPermission: 'game.setting.config.index',
            }
        },
        {
            name: 'game.other.dictionary',
            path: '/game/other/dictionary',
            component: resolve => require(['../pages/game/other/dictionary/Index.vue'], resolve),
            meta: {
                title: 'menu.game.other.dictionary',
            }
        },
        {
            name: 'game.other.broadcast',
            path: '/game/other/broadcast',
            component: resolve => require(['../pages/game/other/broadcast/Index.vue'], resolve),
            meta: {
                title: 'menu.game.other.broadcast',
            }
        },
        {
            name: 'game.other.mail',
            path: '/game/other/mail',
            component: resolve => require(['../pages/game/other/mail/Index.vue'], resolve),
            meta: {
                title: 'menu.game.other.mail',
            }
        },
        {
            name: 'game.other.activity',
            path: '/game/other/activity',
            component: resolve => require(['../pages/game/other/activity/Index.vue'], resolve),
            meta: {
                title: 'menu.game.other.activity',
            }
        },
        {
            name: 'game.config.betting',
            path: '/game/config/betting',
            component: resolve => require(['../pages/game/config/betting/Index.vue'], resolve),
            meta: {
                title: 'menu.game.config.betting',
            }
        },
        {
            name: 'game.config.currency',
            path: '/game/config/currency',
            component: resolve => require(['../pages/game/config/currency/Index.vue'], resolve),
            meta: {
                title: 'menu.game.config.currency',
            }
        },
        {
            name: 'game.config.rtpConfig',
            path: '/game/config/rtpConfig',
            component: resolve => require(['../pages/game/config/rtpConfig/Index.vue'], resolve),
            meta: {
                title: 'menu.game.config.rtpConfig',
            }
        },
        {
            name: 'pay.order.transfer',
            path: '/pay/order/transfer',
            component: resolve => require(['../pages/pay/order/transfer/Index.vue'], resolve),
            meta: {
                title: 'menu.pay.order.transfer',
            }
        },
        {
            name: 'pay.order.wallet',
            path: '/pay/order/wallet',
            component: resolve => require(['../pages/pay/order/wallet/Index.vue'], resolve),
            meta: {
                title: 'menu.pay.order.wallet',
            }
        },
        {
            name: 'system.setting.language',
            path: '/system/setting/language',
            component: resolve => require(['../pages/system/setting/language/Index.vue'], resolve),
            meta: {
                title: 'menu.system.setting.language',
            }
        },
        {
            name: 'system.setting.server',
            path: '/system/setting/server',
            component: resolve => require(['../pages/system/setting/server/Index.vue'], resolve),
            meta: {
                title: 'menu.system.setting.server',
            }
        },
        {
            name: 'system.setting.menu',
            path: '/system/setting/menu',
            component: resolve => require(['../pages/system/setting/menu/Index.vue'], resolve),
            meta: {
                title: 'menu.system.setting.menu',
            }
        },
        {
            name: 'system.user',
            path: '/system/user',
            component: resolve => require(['../pages/system/user/Index.vue'], resolve),
            meta: {
                title: 'menu.system.user',
            }
        },
        {
            name: 'system.permission',
            path: '/system/permission',
            component: resolve => require(['../pages/system/permission/Index.vue'], resolve),
            meta: {
                title: 'menu.system.permission',
            }
        },
        {
            name: 'system.log.activity',
            path: '/system/log/activity',
            component: resolve => require(['../pages/system/log/activity/Index.vue'], resolve),
            meta: {
                title: 'menu.system.log.activity',
            }
        },
        {
            name: 'system.log.login',
            path: '/system/log/login',
            component: resolve => require(['../pages/system/log/login/Index.vue'], resolve),
            meta: {
                title: 'menu.system.log.login',
            }
        },
        {
            name: 'system.testing',
            path: '/system/testing',
            component: resolve => require(['../pages/system/testing/Index.vue'], resolve),
            meta: {
                title: 'menu.system.testing',
            }
        },
        {
            name: 'system.tools.fish-fire',
            path: '/system/tools/fish-fire',
            component: resolve => require(['../pages/system/tools/fish-fire/Index.vue'], resolve),
            meta: {
                title: 'menu.system.tools.fish-fire',
            }
        },
        {
            name: 'system.tools.slot-game',
            path: '/system/tools/slot-game',
            component: resolve => require(['../pages/system/tools/slot-game/Index.vue'], resolve),
            meta: {
                title: 'menu.system.tools.slot-game',
            }
        },
        {
            name: 'home',
            path: '/home',
            component: resolve => require(['../pages/home/Index.vue'], resolve),
            meta: {
                title: 'home.title',
                hasPermissionExcept: true,
            }
        },
        {
            name: 'error.403',
            path: '/error/403',
            component: require('../pages/errors/403.vue').default,
            meta: {
                title: 'error.403',
                hasPermissionExcept: true,
            }
        },
        {
            name: 'error.404',
            path: '/error/404',
            component: require('../pages/errors/404.vue').default,
            meta: {
                title: 'error.404',
                hasPermissionExcept: true,
            }
        },
        {
            path: "*",
            component: require('../pages/Index.vue').default
        }
    ]
});
